package com.octopus.optiworks.controller;

import org.apache.commons.lang.math.NumberUtils;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;

import com.octopus.optiworks.model.*;

public class StepValidator extends CommonValidator {

	@Override
    public boolean supports(Class<?> aClass) {
        return Object.class.isAssignableFrom(aClass);
    }

	@Override
    public void validate(Object o, Errors errors) {
		if(o instanceof Product){
			this.validateProduct((Product)o, errors);
		}else if(o instanceof Step10_1Data){
			this.validateStep10_1((Step10_1Data)o, errors);
		}else if(o instanceof Step10_2Data){
			this.validateStep10_2((Step10_2Data)o, errors);
		}else if(o instanceof Step20Data){
			this.validateStep20((Step20Data)o, errors);
		}else if(o instanceof Step30_1Data){
			this.validateStep30_1((Step30_1Data)o, errors);
		}else if(o instanceof Step30_2Data){
			this.validateStep30_2((Step30_2Data)o, errors);
		}else if(o instanceof Step40Data){
			this.validateStep40((Step40Data)o, errors);
		}else if(o instanceof Step50Data){
			this.validateStep50((Step50Data)o, errors);
		}else if(o instanceof Step60Data){
			this.validateStep60((Step60Data)o, errors);
		}else if(o instanceof Step70Data){
			this.validateStep70((Step70Data)o, errors);
		}else if(o instanceof Step80Data){
			this.validateStep80((Step80Data)o, errors);
		}else if(o instanceof Step90Data){
			this.validateStep90((Step90Data)o, errors);
		}else if(o instanceof Step100_1Data){
			this.validateStep100_1((Step100_1Data)o, errors);
		}else if(o instanceof Step100_2Data){
			this.validateStep100_2((Step100_2Data)o, errors);
		}else if(o instanceof Step100_3Data){
			this.validateStep100_3((Step100_3Data)o, errors);
		}else if(o instanceof Step110Data){
			this.validateStep110((Step110Data)o, errors);
		}else if(o instanceof Step120_1Data){
			this.validateStep120_1((Step120_1Data)o, errors);
		}else if(o instanceof Step120_2Data){
			this.validateStep120_2((Step120_2Data)o, errors);
		}else if(o instanceof Step130Data){
			this.validateStep130((Step130Data)o, errors);
		}else if(o instanceof Step140_1Data){
			this.validateStep140_1((Step140_1Data)o, errors);
		}else if(o instanceof Step140_2Data){
			this.validateStep140_2((Step140_2Data)o, errors);
		}else if(o instanceof Step150Data){
			this.validateStep150((Step150Data)o, errors);
		}else if(o instanceof Step160Data){
			this.validateStep160((Step160Data)o, errors);
		}else if(o instanceof Step170_1Data){
			this.validateStep170_1((Step170_1Data)o, errors);
		}else if(o instanceof Step170_2Data){
			this.validateStep170_2((Step170_2Data)o, errors);
		}else if(o instanceof Step180Data){
			this.validateStep180((Step180Data)o, errors);
		}else if(o instanceof DataSheet){
			this.validateDataSheet((DataSheet)o, errors);
		}
    }
    
    private void validateProduct(Product product, Errors errors) {
    	//Number invalid
    	if(stepValided){
	        if((product.getItuch() == null || product.getItuch().replace(".", "").trim().length()!=3) 
	        		|| (product.getItuch().trim().length()>0 && !NumberUtils.isNumber(product.getItuch())) )
	        	errors.rejectValue( "ituch", "error.product.number.invalid.ituch", "Please enter a valid number with 3 digit: ITU CH#." );
	        if((product.getItunm() == null || product.getItunm().replace(".", "").trim().length()!=7) 
	        		|| (product.getItunm().trim().length()>0 && !NumberUtils.isNumber(product.getItunm())) )
	        	errors.rejectValue( "itunm", "error.product.number.invalid.itunm", "Please enter a valid number with 7 digit: ITU λ (nm)." );
	        if(product.getFrequency() == null || !NumberUtils.isNumber(product.getFrequency()) )
	        	errors.rejectValue( "frequency", "error.product.number.invalid.frequency", "Please enter a valid number: Frequency(GHz)." );
	        if(product.getChannelPb2() == null || !NumberUtils.isNumber(product.getChannelPb2()) )
	        	errors.rejectValue( "channelPb2", "error.product.number.invalid.channelPb2", "Please enter a valid number: Channel PB/2." );
    	}
    	//Length invalid
    	if(stepValided){
	    	if(product.getWono() == null || product.getWono().trim().length() != 10)
	    		errors.rejectValue( "wono", "error.product.length.invalid.wono", "Please specify W/O No. with 10 chars." );
	    	if(product.getPn() == null || product.getPn().trim().length() != 20)
	    		errors.rejectValue( "pn", "error.product.length.invalid.pn", "Please specify P/N with 20 chars." );
	    	if(product.getInternalSn() == null || product.getInternalSn().trim().length() != 10)
	    		errors.rejectValue( "internalSn", "error.product.length.invalid.internalSn", "Please specify Internal S/N with 10 chars." );
    	}
    }
    
    private void validateStep10_1(Step10_1Data step, Errors errors) {
    	//Length invalid
    	if(stepValided){
	    	if(step.getTestLightCode() == null || step.getTestLightCode().trim().length() != 20)
	    		errors.rejectValue( "testLightCode", "error.user.length.invalid.testLightCode", "Please specify Test Light Code with 20 chars." );
	    	if(step.getFilterId() == null || step.getFilterId().trim().length() != 20)
	    		errors.rejectValue( "filterId", "error.step10.length.invalid.filterId", "Please specify Filter ID with 20 chars." );
	    	if(step.getGrinleosCode() == null || step.getGrinleosCode().trim().length() != 20)
	    		errors.rejectValue( "grinleosCode", "error.step10.length.invalid.grinleosCode", "Please specify Grinleos Code with 20 chars." );
	    	if(step.getFilterCode() == null || step.getFilterCode().trim().length() != 20)
	    		errors.rejectValue( "filterCode", "error.step10.length.invalid.filterCode", "Please specify Filter Code with 20 chars." );
	    	if(step.getPigtailLn() == null || step.getPigtailLn().trim().length() != 10)
	    		errors.rejectValue( "pigtailLn", "error.step10.length.invalid.pigtailLn", "Please specify Pigtail LN with 10 chars." );
	    	if(step.getPigtailActual() == null || step.getPigtailActual().trim().length() != 20)
	    		errors.rejectValue( "pigtailActual", "error.step10.length.invalid.pigtailActual", "Please specify Actual Pigtail with 20 chars." );
	    	if(step.getPigtailNeed() == null || step.getPigtailNeed().trim().length() != 20)
	    		errors.rejectValue( "pigtailNeed", "error.step10.length.invalid.pigtailNeed", "Please specify Needed Pigtail with 20 chars." );
    	}
    }
    
    private void validateStep10_2(Step10_2Data step, Errors errors) {
    	//Length invalid
    	if(stepValided){

    	}
    }
    
    private void validateStep20(Step20Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gumCode", "error.step20.empty.gumCode", "Please specify Gum Code.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "beginTime", "error.step100.empty.ovenEnterTime", "Please specify Enter Oven Time.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "endTime", "error.step100.empty.ovenLeaveTime", "Please specify Leave Oven Time.");
    	}
    	//Length invalid
    	if(stepValided){
	    	if(step.getGumCode() == null || step.getGumCode().trim().length() != 20)
	    		errors.rejectValue( "gumCode", "error.step20.length.invalid.gumCode", "Please specify Gum Code with 20 chars." );
    	}
    }
    
    private void validateStep30_1(Step30_1Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gumCode", "error.step20.empty.gumCode", "Please specify Gum Code.");
       		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "beginTime", "error.step100.empty.ovenEnterTime", "Please specify Enter Oven Time.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "endTime", "error.step100.empty.ovenLeaveTime", "Please specify Leave Oven Time.");
    	}
    	//Length invalid
    	if(stepValided){
	    	if(step.getGumCode() == null || step.getGumCode().trim().length() != 20)
	    		errors.rejectValue( "gumCode", "error.step20.length.invalid.gumCode", "Please specify Gum Code with 20 chars." );
    	}
    	//Number invalid
    	if(stepValided){
    	}
    }
    
    private void validateStep30_2(Step30_2Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    	}
    	//Length invalid
    	if(stepValided){
	    	if(step.getTestLightCode() == null || step.getTestLightCode().trim().length() != 20)
	    		errors.rejectValue( "testLightCode", "error.user.length.invalid.testLightCode", "Please specify Test Light Code with 20 chars." );
    	}
    	//Number invalid
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gumBeforeIl", "error.step30.empty.gumBeforeIl", "Please specify Gum Before IL.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gumAfterIl", "error.step30.empty.gumAfterIl", "Please specify Gum After IL.");
	        if((step.getGumBeforeIl() == null || step.getGumBeforeIl().replace(".", "").trim().length()!=3) 
	        		|| (step.getGumBeforeIl().trim().length()>0 && !NumberUtils.isNumber(step.getGumBeforeIl())) )
	        	errors.rejectValue( "gumBeforeIl", "error.step30.number.invalid.gumBeforeIl", "Please enter a valid number with 3 digit: Gum Before IL." );
	        if((step.getGumAfterIl() == null || step.getGumAfterIl().replace(".", "").trim().length()!=3) 
	        		|| (step.getGumAfterIl().trim().length()>0 && !NumberUtils.isNumber(step.getGumAfterIl())) )
	        	errors.rejectValue( "gumAfterIl", "error.step30.number.invalid.gumAfterIl", "Please enter a valid number with 3 digit: Gum After IL." );
    	}
    }
    
    private void validateStep40(Step40Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gumCode", "error.step20.empty.gumCode", "Please specify Gum Code.");
       		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "beginTime", "error.step100.empty.ovenEnterTime", "Please specify Enter Oven Time.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "endTime", "error.step100.empty.ovenLeaveTime", "Please specify Leave Oven Time.");
    	}
    	//Length invalid
    	if(stepValided){
	    	if(step.getGumCode() == null || step.getGumCode().trim().length() != 20)
	    		errors.rejectValue( "gumCode", "error.step20.length.invalid.gumCode", "Please specify Gum Code with 20 chars." );
    	}
    }
    
    private void validateStep50(Step50Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gumCode", "error.step20.empty.gumCode", "Please specify Gum Code.");
       		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "beginTime", "error.step100.empty.ovenEnterTime", "Please specify Enter Oven Time.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "endTime", "error.step100.empty.ovenLeaveTime", "Please specify Leave Oven Time.");
    	}
    	//Length invalid
    	if(stepValided){
	    	if(step.getGumCode() == null || step.getGumCode().trim().length() != 20)
	    		errors.rejectValue( "gumCode", "error.step20.length.invalid.gumCode", "Please specify Gum Code with 20 chars." );
    	}
    }
    
    private void validateStep60(Step60Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gumCode", "error.step20.empty.gumCode", "Please specify Gum Code.");
       		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "beginTime", "error.step100.empty.ovenEnterTime", "Please specify Enter Oven Time.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "endTime", "error.step100.empty.ovenLeaveTime", "Please specify Leave Oven Time.");
    	}
    	//Length invalid
    	if(stepValided){
	    	if(step.getGumCode() == null || step.getGumCode().trim().length() != 20)
	    		errors.rejectValue( "gumCode", "error.step20.length.invalid.gumCode", "Please specify Gum Code with 20 chars." );
    	}
    }
    
    private void validateStep70(Step70Data step, Errors errors) {
    	//Input invalid
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dateBegin", "error.step70.empty.dateBegin", "Please specify Date Begin.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dateEnd", "error.step70.empty.dateEnd", "Please specify Date End.");
//    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "timeBegin", "error.step70.empty.timeBegin", "Please specify Time Begin.");
//    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "timeEnd", "error.step70.empty.timeEnd", "Please specify Time End.");
    	}
    }
    
    private void validateStep80(Step80Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlRportParm1", "error.step80.empty.rlRportParm1", "Please specify RL(R-Port) / atAdj_L.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlRportParm3", "error.step80.empty.rlRportParm3", "Please specify RL(R-Port) / atAdj_R.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlCportParm1", "error.step80.empty.rlCportParm1", "Please specify RL(C-Port) / atAdj_L.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlCportParm2", "error.step80.empty.rlCportParm2", "Please specify RL(C-Port) / atITU.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlCportParm3", "error.step80.empty.rlCportParm3", "Please specify RL(C-Port) / atAdj_R.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dirPrParm2", "error.step80.empty.dirPrParm2", "Please specify  Dir(P->R) / atITU.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dirRpParm1", "error.step80.empty.dirRpParm1", "Please specify Dir(R->P) / atAdj_L.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dirRpParm3", "error.step80.empty.dirRpParm3", "Please specify  Dir(R->P) / atAdj_R.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "reflectIlpdl", "error.step80.empty.reflectIlpdl", "Please specify Reflect IL/PDL.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "reflectIlpdlHigh", "error.step80.empty.reflectIlpdlHigh", "Please specify Reflect IL/PDL High.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "transPdl", "error.step80.empty.transPdl", "Please specify Trans PDL.");
    	}
    	//Number invalid
    	if(stepValided){
	        if((step.getRlRportParm1() == null || step.getRlRportParm1().replace(".", "").trim().length()!=3) 
	        		|| (step.getRlRportParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRlRportParm1())) )
	        	errors.rejectValue( "rlRportParm1", "error.step80.number.invalid.rlRportParm1", "Please enter a valid number with 3 digit: RL(R-Port) / atAdj_L." );
	        if((step.getRlRportParm3() == null || step.getRlRportParm3().replace(".", "").trim().length()!=3) 
	        		|| (step.getRlRportParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRlRportParm3())) )
	        	errors.rejectValue( "rlRportParm3", "error.step80.number.invalid.rlRportParm3", "Please enter a valid number with 3 digit: RL(R-Port) / atAdj_R." );
	        if((step.getRlCportParm1() == null || step.getRlCportParm1().replace(".", "").trim().length()!=3) 
	        		|| (step.getRlCportParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRlCportParm1())) )
	        	errors.rejectValue( "rlCportParm1", "error.step80.number.invalid.rlCportParm1", "Please enter a valid number with 3 digit: RL(C-Port) / atAdj_L." );
	        if((step.getRlCportParm2() == null || step.getRlCportParm2().replace(".", "").trim().length()!=3) 
	        		|| (step.getRlCportParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRlCportParm2())) )
	        	errors.rejectValue( "rlCportParm2", "error.step80.number.invalid.rlCportParm2", "Please enter a valid number with 3 digit: RL(C-Port) / atITU." );
	        if((step.getRlCportParm3() == null || step.getRlCportParm3().replace(".", "").trim().length()!=3) 
	        		|| (step.getRlCportParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRlCportParm3())) )
	        	errors.rejectValue( "rlCportParm3", "error.step80.number.invalid.rlCportParm3", "Please enter a valid number with 3 digit: RL(C-Port) / atAdj_R." );
	        if((step.getDirPrParm2() == null || step.getDirPrParm2().replace(".", "").trim().length()!=3) 
	        		|| (step.getDirPrParm2().trim().length()>0 && !NumberUtils.isNumber(step.getDirPrParm2())) )
	        	errors.rejectValue( "dirPrParm2", "error.step80.number.invalid.dirPrParm2", "Please enter a valid number with 3 digit: Dir(P->R) / atITU." );
	        if((step.getDirRpParm1() == null || step.getDirRpParm1().replace(".", "").trim().length()!=3) 
	        		|| (step.getDirRpParm1().trim().length()>0 && !NumberUtils.isNumber(step.getDirRpParm1())) )
	        	errors.rejectValue( "dirRpParm1", "error.step80.number.invalid.dirRpParm1", "Please enter a valid number with 3 digit: Dir(R->P) / atAdj_L." );
	        if((step.getDirRpParm3() == null || step.getDirRpParm3().replace(".", "").trim().length()!=3) 
	        		|| (step.getDirRpParm3().trim().length()>0 && !NumberUtils.isNumber(step.getDirRpParm3())) )
	        	errors.rejectValue( "dirRpParm3", "error.step80.number.invalid.dirRpParm3", "Please enter a valid number with 3 digit: Dir(R->P) / atAdj_R." );
	        if((step.getReflectIlpdl() == null || step.getReflectIlpdl().replace(".", "").trim().length()!=3) 
	        		|| (step.getReflectIlpdl().trim().length()>0 && !NumberUtils.isNumber(step.getReflectIlpdl())) )
	        	errors.rejectValue( "reflectIlpdl", "error.step80.number.invalid.reflectIlpdl", "Please enter a valid number with 3 digit: Reflect IL/PDL." );
	        if((step.getReflectIlpdlHigh() == null || step.getReflectIlpdlHigh().replace(".", "").trim().length()!=3) 
	        		|| (step.getReflectIlpdlHigh().trim().length()>0 && !NumberUtils.isNumber(step.getReflectIlpdlHigh())) )
	        	errors.rejectValue( "reflectIlpdlHigh", "error.step80.number.invalid.reflectIlpdlHigh", "Please enter a valid number with 3 digit: Reflect IL/PDL High." );
	        if((step.getTransPdl() == null || step.getTransPdl().replace(".", "").trim().length()!=3) 
	        		|| (step.getTransPdl().trim().length()>0 && !NumberUtils.isNumber(step.getTransPdl())) )
	        	errors.rejectValue( "transPdl", "error.step80.number.invalid.transPdl", "Please enter a valid number with 3 digit: Trans PDL." );
    	}
    	//Length invalid
    	if(stepValided){
	    	if(step.getTestLightCode() == null || step.getTestLightCode().trim().length() != 20)
	    		errors.rejectValue( "testLightCode", "error.user.length.invalid.testLightCode", "Please specify Test Light Code with 20 chars." );
    	}
    }
    
    private void validateStep90(Step90Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "transIlParm1", "error.step90.empty.transIlParm1", "Please specify Transmission IL(dB) before jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "transIlParm2", "error.step90.empty.transIlParm2", "Please specify Transmission IL(dB) after jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pdlParm1", "error.step90.empty.pdlParm1", "Please specify PDL(dB) before jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pdlParm2", "error.step90.empty.pdlParm2", "Please specify PDL(dB) after jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "prParm1", "error.step90.empty.prParm1", "Please specify P->R(ITU) before jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "prParm2", "error.step90.empty.prParm2", "Please specify P->R(ITU) after jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pituParm1", "error.step90.empty.pituParm1", "Please specify P/ITU before jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pituParm2", "error.step90.empty.pituParm2", "Please specify P/ITU after jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cadjlParm1", "error.step90.empty.cadjlParm1", "Please specify C/Adj-L before jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cadjlParm2", "error.step90.empty.cadjlParm2", "Please specify C/Adj-L after jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cituParm1", "error.step90.empty.cituParm1", "Please specify C/ITU before jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cituParm2", "error.step90.empty.cituParm2", "Please specify C/ITU after jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cadjrParm1", "error.step90.empty.cadjrParm1", "Please specify C/Adj-R before jointing.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cadjrParm2", "error.step90.empty.cadjrParm2", "Please specify C/Adj-R after jointing.");
    	}
    	//Number invalid
    	if(stepValided){
	        if((step.getTransIlParm1() == null || step.getTransIlParm1().replace(".", "").trim().length()!=3) 
	        		|| (step.getTransIlParm1().trim().length()>0 && !NumberUtils.isNumber(step.getTransIlParm1())) )
	        	errors.rejectValue( "transIlParm1", "error.step90.number.invalid.transIlParm1", "Please enter a valid number with 3 digit: Transmission IL(dB) before jointing." );
	        if((step.getTransIlParm2() == null || step.getTransIlParm2().replace(".", "").trim().length()!=3) 
	        		|| (step.getTransIlParm2().trim().length()>0 && !NumberUtils.isNumber(step.getTransIlParm2())) )
	        	errors.rejectValue( "transIlParm2", "error.step90.number.invalid.transIlParm2", "Please enter a valid number with 3 digit: Transmission IL(dB) after jointing." );
	        if((step.getPdlParm1() == null || step.getPdlParm1().replace(".", "").trim().length()!=3) 
	        		|| (step.getPdlParm1().trim().length()>0 && !NumberUtils.isNumber(step.getPdlParm1())) )
	        	errors.rejectValue( "pdlParm1", "error.step90.number.invalid.pdlParm1", "Please enter a valid number with 3 digit: PDL(dB) before jointing." );
	        if((step.getPdlParm2() == null || step.getPdlParm2().replace(".", "").trim().length()!=3) 
	        		|| (step.getPdlParm2().trim().length()>0 && !NumberUtils.isNumber(step.getPdlParm2())) )
	        	errors.rejectValue( "pdlParm2", "error.step90.number.invalid.pdlParm2", "Please enter a valid number with 3 digit: PDL(dB) after jointing." );
	        if((step.getPrParm1() == null || step.getPrParm1().replace(".", "").trim().length()!=3) 
	        		|| (step.getPrParm1().trim().length()>0 && !NumberUtils.isNumber(step.getPrParm1())) )
	        	errors.rejectValue( "prParm1", "error.step90.number.invalid.prParm1", "Please enter a valid number with 3 digit: P->R(ITU) before jointing." );
	        if((step.getPrParm2() == null || step.getPrParm2().replace(".", "").trim().length()!=3) 
	        		|| (step.getPrParm2().trim().length()>0 && !NumberUtils.isNumber(step.getPrParm2())) )
	        	errors.rejectValue( "prParm2", "error.step90.number.invalid.prParm2", "Please enter a valid number with 3 digit: P->R(ITU) after jointing." );
	        if((step.getPituParm1() == null || step.getPituParm1().replace(".", "").trim().length()!=3) 
	        		|| (step.getPituParm1().trim().length()>0 && !NumberUtils.isNumber(step.getPituParm1())) )
	        	errors.rejectValue( "pituParm1", "error.step90.number.invalid.pituParm1", "Please enter a valid number with 3 digit: P/ITU before jointing." );
	        if((step.getPituParm2() == null || step.getPituParm2().replace(".", "").trim().length()!=3) 
	        		|| (step.getPituParm2().trim().length()>0 && !NumberUtils.isNumber(step.getPituParm2())) )
	        	errors.rejectValue( "pituParm2", "error.step90.number.invalid.pituParm2", "Please enter a valid number with 3 digit: P/ITU after jointing." );
	        if((step.getCadjlParm1() == null || step.getCadjlParm1().replace(".", "").trim().length()!=3) 
	        		|| (step.getCadjlParm1().trim().length()>0 && !NumberUtils.isNumber(step.getCadjlParm1())) )
	        	errors.rejectValue( "cadjlParm1", "error.step90.number.invalid.cadjlParm1", "Please enter a valid number with 3 digit: C/Adj-L before jointing." );
	        if((step.getCadjlParm2() == null || step.getCadjlParm2().replace(".", "").trim().length()!=3) 
	        		|| (step.getCadjlParm2().trim().length()>0 && !NumberUtils.isNumber(step.getCadjlParm2())) )
	        	errors.rejectValue( "cadjlParm2", "error.step90.number.invalid.cadjlParm2", "Please enter a valid number with 3 digit: C/Adj-L after jointing." );
	        if((step.getCituParm1() == null || step.getCituParm1().replace(".", "").trim().length()!=3) 
	        		|| (step.getCituParm1().trim().length()>0 && !NumberUtils.isNumber(step.getCituParm1())) )
	        	errors.rejectValue( "cituParm1", "error.step90.number.invalid.cituParm1", "Please enter a valid number with 3 digit: C/ITU before jointing." );
	        if((step.getCituParm2() == null || step.getCituParm2().replace(".", "").trim().length()!=3) 
	        		|| (step.getCituParm2().trim().length()>0 && !NumberUtils.isNumber(step.getCituParm2())) )
	        	errors.rejectValue( "cituParm2", "error.step90.number.invalid.cituParm2", "Please enter a valid number with 3 digit: C/ITU after jointing." );
	        if((step.getCadjrParm1() == null || step.getCadjrParm1().replace(".", "").trim().length()!=3) 
	        		|| (step.getCadjrParm1().trim().length()>0 && !NumberUtils.isNumber(step.getCadjrParm1())) )
	        	errors.rejectValue( "cadjrParm1", "error.step90.number.invalid.cadjrParm1", "Please enter a valid number with 3 digit: C/Adj-R before jointing." );
	        if((step.getCadjrParm2() == null || step.getCadjrParm2().replace(".", "").trim().length()!=3) 
	        		|| (step.getCadjrParm2().trim().length()>0 && !NumberUtils.isNumber(step.getCadjrParm2())) )
	        	errors.rejectValue( "cadjrParm2", "error.step90.number.invalid.cadjrParm2", "Please enter a valid number with 3 digit: C/Adj-R after jointing." );
    	}
    	//Length invalid
    	if(stepValided){
	    	if(step.getTestLightCode() == null || step.getTestLightCode().trim().length() != 20)
	    		errors.rejectValue( "testLightCode", "error.user.length.invalid.testLightCode", "Please specify Test Light Code with 20 chars." );
    	}
    }
    
    private void validateStep100_1(Step100_1Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gumCode", "error.step100.empty.gumCode", "Please specify Gum Code.");
    	}
    	//Length invalid
    	if(stepValided){
	    	if(step.getGumCode() == null || step.getGumCode().trim().length() != 20)
	    		errors.rejectValue( "gumCode", "error.step20.length.invalid.gumCode", "Please specify Gum Code with 20 chars." );
    	}
    }
    
    private void validateStep100_2(Step100_2Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "ovenEnterTime", "error.step100.empty.ovenEnterTime", "Please specify Enter Oven Time.");
    	}
    }
    
    private void validateStep100_3(Step100_3Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "ovenLeaveTime", "error.step100.empty.ovenLeaveTime", "Please specify Leave Oven Time.");
    	}
    }
    
    private void validateStep110(Step110Data step, Errors errors) {
    	//Length invalid
    	if(step.getRemark().trim().length() > 50)
    		errors.rejectValue( "remark", "error.step110.length.invalid.remark", "Please specify Remark less than 50 chars." );
    }
    
    private void validateStep120_1(Step120_1Data step, Errors errors) {
    	//Input invalid
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cycleEnterTime", "error.step120.empty.cycleEnterTime", "Please specify Cycle Enter Time.");
    	}
    }
    
    private void validateStep120_2(Step120_2Data step, Errors errors) {
    	//Input invalid
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cycleLeaveTime", "error.step120.empty.cycleLeaveTime", "Please specify Cycle Leave Time.");
    	}
    }
    
    private void validateStep130(Step130Data step, Errors errors) {

    }
    
    private void validateStep140_1(Step140_1Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    	}
    	//Number invalid
        if((step.getIlParm1().trim().length()>0 && !NumberUtils.isNumber(step.getIlParm1())) 
        		|| (step.getIlParm2().trim().length()>0 && !NumberUtils.isNumber(step.getIlParm2())) 
        		|| (step.getIlParm3().trim().length()>0 && !NumberUtils.isNumber(step.getIlParm3())) )
        	errors.rejectValue( "ilParm1", "error.step140.number.invalid.il", "Please enter a valid number: IL" );
        if((step.getRippleParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRippleParm1())) 
        		|| (step.getRippleParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRippleParm2())) 
        		|| (step.getRippleParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRippleParm3())) )
        	errors.rejectValue( "rippleParm1", "error.step140.number.invalid.ripple", "Please enter a valid number: Ripple" );
        if((step.getIsolParm1().trim().length()>0 && !NumberUtils.isNumber(step.getIsolParm1())) 
        		|| (step.getIsolParm2().trim().length()>0 && !NumberUtils.isNumber(step.getIsolParm2())) 
        		|| (step.getIsolParm3().trim().length()>0 && !NumberUtils.isNumber(step.getIsolParm3())) )
        	errors.rejectValue( "isolParm1", "error.step140.number.invalid.isol", "Please enter a valid number: ISO-L" );
        if((step.getIsorParm1().trim().length()>0 && !NumberUtils.isNumber(step.getIsorParm1())) 
        		|| (step.getIsorParm2().trim().length()>0 && !NumberUtils.isNumber(step.getIsorParm2())) 
        		|| (step.getIsorParm3().trim().length()>0 && !NumberUtils.isNumber(step.getIsorParm3())) )
        	errors.rejectValue( "isorParm1", "error.step140.number.invalid.isor", "Please enter a valid number: ISO-R" );
        if((step.getNisolParm1().trim().length()>0 && !NumberUtils.isNumber(step.getNisolParm1())) 
        		|| (step.getNisolParm2().trim().length()>0 && !NumberUtils.isNumber(step.getNisolParm2())) 
        		|| (step.getNisolParm3().trim().length()>0 && !NumberUtils.isNumber(step.getNisolParm3())) )
        	errors.rejectValue( "nisolParm1", "error.step140.number.invalid.nisol", "Please enter a valid number: N-ISO-L" );
        if((step.getNisorParm1().trim().length()>0 && !NumberUtils.isNumber(step.getNisorParm1())) 
        		|| (step.getNisorParm2().trim().length()>0 && !NumberUtils.isNumber(step.getNisorParm2())) 
        		|| (step.getNisorParm3().trim().length()>0 && !NumberUtils.isNumber(step.getNisorParm3())) )
        	errors.rejectValue( "nisorParm1", "error.step140.number.invalid.nisor", "Please enter a valid number: N-ISO-R" );
        if((step.getPdlPb2Parm1().trim().length()>0 && !NumberUtils.isNumber(step.getPdlPb2Parm1())) 
        		|| (step.getPdlPb2Parm2().trim().length()>0 && !NumberUtils.isNumber(step.getPdlPb2Parm2())) 
        		|| (step.getPdlPb2Parm3().trim().length()>0 && !NumberUtils.isNumber(step.getPdlPb2Parm3())) )
        	errors.rejectValue( "pdlPb2Parm1", "error.step140.number.invalid.pdlPb2", "Please enter a valid number: PDL-PB/2" );
        if((step.getPdlItuParm1().trim().length()>0 && !NumberUtils.isNumber(step.getPdlItuParm1())) 
        		|| (step.getPdlItuParm2().trim().length()>0 && !NumberUtils.isNumber(step.getPdlItuParm2())) 
        		|| (step.getPdlItuParm3().trim().length()>0 && !NumberUtils.isNumber(step.getPdlItuParm3())) )
        	errors.rejectValue( "pdlItuParm1", "error.step140.number.invalid.pdlItu", "Please enter a valid number: PDL-ITU" );
        if((step.getPdlaPb2Parm1().trim().length()>0 && !NumberUtils.isNumber(step.getPdlaPb2Parm1())) 
        		|| (step.getPdlaPb2Parm2().trim().length()>0 && !NumberUtils.isNumber(step.getPdlaPb2Parm2())) 
        		|| (step.getPdlaPb2Parm3().trim().length()>0 && !NumberUtils.isNumber(step.getPdlaPb2Parm3())) )
        	errors.rejectValue( "pdlaPb2Parm1", "error.step140.number.invalid.pdlaPb2", "Please enter a valid number: PDL+PB/2" );
        if((step.getMinRisoParm1().trim().length()>0 && !NumberUtils.isNumber(step.getMinRisoParm1())) 
        		|| (step.getMinRisoParm2().trim().length()>0 && !NumberUtils.isNumber(step.getMinRisoParm2())) 
        		|| (step.getMinRisoParm3().trim().length()>0 && !NumberUtils.isNumber(step.getMinRisoParm3())) )
        	errors.rejectValue( "minRisoParm1", "error.step140.number.invalid.minRiso", "Please enter a valid number: Min-R-ISO" );
        if((step.getRillParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRillParm1())) 
        		|| (step.getRillParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRillParm2())) 
        		|| (step.getRillParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRillParm3())) )
        	errors.rejectValue( "rillParm1", "error.step140.number.invalid.rill", "Please enter a valid number: R IL-L" );
        if((step.getRilrParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRilrParm1())) 
        		|| (step.getRilrParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRilrParm2())) 
        		|| (step.getRilrParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRilrParm3())) )
        	errors.rejectValue( "rilrParm1", "error.step140.number.invalid.rilr", "Please enter a valid number: R IL-R" );
        if((step.getRipplelParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRipplelParm1())) 
        		|| (step.getRipplelParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRipplelParm2())) 
        		|| (step.getRipplelParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRipplelParm3())) )
        	errors.rejectValue( "ripplelParm1", "error.step140.number.invalid.ripplel", "Please enter a valid number: Ripple/L" );
        if((step.getRipplerParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRipplerParm1())) 
        		|| (step.getRipplerParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRipplerParm2())) 
        		|| (step.getRipplerParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRipplerParm3())) )
        	errors.rejectValue( "ripplerParm1", "error.step140.number.invalid.rippler", "Please enter a valid number: Ripple/R" );
    	//Length invalid
    	if(stepValided){
	    	if(step.getTestLightCode() == null || step.getTestLightCode().trim().length() != 20)
	    		errors.rejectValue( "testLightCode", "error.user.length.invalid.testLightCode", "Please specify Test Light Code with 20 chars." );
    	}
    }
    
    private void validateStep140_2(Step140_2Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlRportParm1", "error.step140.empty.rlRportParm1", "Please specify RL(R-Port)/at Adj_L.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlPportParm2", "error.step140.empty.rlPportParm2", "Please specify RL(P-Port)/at ITU.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlRportParm3", "error.step140.empty.rlRportParm3", "Please specify RL(R-Port)/at Adj_R.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlCportParm1", "error.step140.empty.rlCportParm1", "Please specify RL(C-Port))/at Adj_L.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlCportParm2", "error.step140.empty.rlCportParm2", "Please specify RL(C-Port))/at ITU.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlCportParm3", "error.step140.empty.rlCportParm3", "Please specify RL(C-Port))/at Adj_R.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dirPrParm2", "error.step140.empty.dirPrParm2", "Please specify Dir(P->R)/at ITU.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dirRpParm1", "error.step140.empty.dirRpParm1", "Please specify Dir(R->P)/at Adj_L.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dirRpParm3", "error.step140.empty.dirRpParm3", "Please specify Dir(R->P)/at Adj_R.");
    	}
    	//Number invalid
        if((step.getRlPportParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRlPportParm2())) 
        		|| (step.getRlPportParm2().trim().length()>0 && step.getRlPportParm2().replace(".", "").trim().length() > 3))
        	errors.rejectValue( "rlPportParm1", "error.step140.number.invalid.rlPport", "Please enter a valid number within 3 digit: RL(P-Port)" );
        if((step.getRlRportParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRlRportParm1())) 
        		|| (step.getRlRportParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRlRportParm3())) 
        		|| (step.getRlRportParm1().trim().length()>0 && step.getRlRportParm1().replace(".", "").trim().length() > 3)
        		|| (step.getRlRportParm3().trim().length()>0 && step.getRlRportParm3().replace(".", "").trim().length() > 3))
        	errors.rejectValue( "rlRportParm1", "error.step140.number.invalid.rlRport", "Please enter a valid number within 3 digit: RL(R-Port)" );
        if((step.getRlCportParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRlCportParm1())) 
        		|| (step.getRlCportParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRlCportParm2())) 
        		|| (step.getRlCportParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRlCportParm3())) 
        		|| (step.getRlCportParm1().trim().length()>0 && step.getRlCportParm1().replace(".", "").trim().length() > 3)
        		|| (step.getRlCportParm2().trim().length()>0 && step.getRlCportParm2().replace(".", "").trim().length() > 3)
        		|| (step.getRlCportParm3().trim().length()>0 && step.getRlCportParm3().replace(".", "").trim().length() > 3))
        	errors.rejectValue( "rlCportParm1", "error.step140.number.invalid.rlCport", "Please enter a valid number within 3 digit: RL(C-Port)" );
        if((step.getDirPrParm2().trim().length()>0 && !NumberUtils.isNumber(step.getDirPrParm2())) 
        		|| (step.getDirPrParm2().trim().length()>0 && step.getDirPrParm2().replace(".", "").trim().length() > 3))
        	errors.rejectValue( "dirPrParm2", "error.step140.number.invalid.dirPr", "Please enter a valid number within 3 digit: Dir(P->R)" );
        if((step.getDirRpParm1().trim().length()>0 && !NumberUtils.isNumber(step.getDirRpParm1())) 
        		|| (step.getDirRpParm3().trim().length()>0 && !NumberUtils.isNumber(step.getDirRpParm3())) 
        		|| (step.getDirRpParm1().trim().length()>0 && step.getDirRpParm1().replace(".", "").trim().length() > 3)
        		|| (step.getDirRpParm3().trim().length()>0 && step.getDirRpParm3().replace(".", "").trim().length() > 3))
        	errors.rejectValue( "dirRpParm1", "error.step140.number.invalid.dirRp", "Please enter a valid number within 3 digit: Dir(R->P)" );
    	//Length invalid
    	if(stepValided){
	    	if(step.getTestLightCode2() == null || step.getTestLightCode2().trim().length() != 20)
	    		errors.rejectValue( "testLightCode2", "error.user.length.invalid.testLightCode", "Please specify Test Light Code with 20 chars." );
    	}
    }
    
    private void validateStep150(Step150Data step, Errors errors) {

    }
    
    private void validateStep160(Step160Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "tilPdl", "error.step160.empty.tilPdl", "Please specify T-IL/PDL.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rillPdl", "error.step160.empty.rillPdl", "Please specify R-IL-L/PDL.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rilrPdl", "error.step160.empty.rilrPdl", "Please specify R-IL-R/PDL.");
    	}
    	//Number invalid
        if((step.getTilPdl().trim().length()>0 && step.getTilPdl().replace(".", "").trim().length()!=3))
        	errors.rejectValue( "tilPdl", "error.step160.number.invalid.tilPdl", "Please enter a valid number with 3 digit: T-IL/PDL." );
        if((step.getRillPdl().trim().length()>0 && step.getRillPdl().replace(".", "").trim().length()!=3))
        	errors.rejectValue( "rillPdl", "error.step160.number.invalid.rillPdl", "Please enter a valid number with 3 digit: R-IL-L/PDL." );
        if((step.getRilrPdl().trim().length()>0 && step.getRilrPdl().replace(".", "").trim().length()!=3))
        	errors.rejectValue( "rilrPdl", "error.step160.number.invalid.rilrPdl", "Please enter a valid number with 3 digit: R-IL-R/PDL." );
    	//Length invalid
    	if(stepValided){
	    	if(step.getTestLightCode() == null || step.getTestLightCode().trim().length() != 20)
	    		errors.rejectValue( "testLightCode", "error.user.length.invalid.testLightCode", "Please specify Test Light Code with 20 chars." );
    	}
    }
    
    private void validateStep170_1(Step170_1Data step, Errors errors) {
    	//Input empty
    	if(stepValided){

    	}
    	//Number invalid
        if((step.getIlParm1().trim().length()>0 && !NumberUtils.isNumber(step.getIlParm1())) 
        		|| (step.getIlParm2().trim().length()>0 && !NumberUtils.isNumber(step.getIlParm2())) 
        		|| (step.getIlParm3().trim().length()>0 && !NumberUtils.isNumber(step.getIlParm3())) )
        	errors.rejectValue( "ilParm1", "error.step140.number.invalid.il", "Please enter a valid number: IL" );
        if((step.getRippleParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRippleParm1())) 
        		|| (step.getRippleParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRippleParm2())) 
        		|| (step.getRippleParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRippleParm3())) )
        	errors.rejectValue( "rippleParm1", "error.step140.number.invalid.ripple", "Please enter a valid number: Ripple" );
        if((step.getIsolParm1().trim().length()>0 && !NumberUtils.isNumber(step.getIsolParm1())) 
        		|| (step.getIsolParm2().trim().length()>0 && !NumberUtils.isNumber(step.getIsolParm2())) 
        		|| (step.getIsolParm3().trim().length()>0 && !NumberUtils.isNumber(step.getIsolParm3())) )
        	errors.rejectValue( "isolParm1", "error.step140.number.invalid.isol", "Please enter a valid number: ISO-L" );
        if((step.getIsorParm1().trim().length()>0 && !NumberUtils.isNumber(step.getIsorParm1())) 
        		|| (step.getIsorParm2().trim().length()>0 && !NumberUtils.isNumber(step.getIsorParm2())) 
        		|| (step.getIsorParm3().trim().length()>0 && !NumberUtils.isNumber(step.getIsorParm3())) )
        	errors.rejectValue( "isorParm1", "error.step140.number.invalid.isor", "Please enter a valid number: ISO-R" );
        if((step.getNisolParm1().trim().length()>0 && !NumberUtils.isNumber(step.getNisolParm1())) 
        		|| (step.getNisolParm2().trim().length()>0 && !NumberUtils.isNumber(step.getNisolParm2())) 
        		|| (step.getNisolParm3().trim().length()>0 && !NumberUtils.isNumber(step.getNisolParm3())) )
        	errors.rejectValue( "nisolParm1", "error.step140.number.invalid.nisol", "Please enter a valid number: N-ISO-L" );
        if((step.getNisorParm1().trim().length()>0 && !NumberUtils.isNumber(step.getNisorParm1())) 
        		|| (step.getNisorParm2().trim().length()>0 && !NumberUtils.isNumber(step.getNisorParm2())) 
        		|| (step.getNisorParm3().trim().length()>0 && !NumberUtils.isNumber(step.getNisorParm3())) )
        	errors.rejectValue( "nisorParm1", "error.step140.number.invalid.nisor", "Please enter a valid number: N-ISO-R" );
        if((step.getPdlPb2Parm1().trim().length()>0 && !NumberUtils.isNumber(step.getPdlPb2Parm1())) 
        		|| (step.getPdlPb2Parm2().trim().length()>0 && !NumberUtils.isNumber(step.getPdlPb2Parm2())) 
        		|| (step.getPdlPb2Parm3().trim().length()>0 && !NumberUtils.isNumber(step.getPdlPb2Parm3())) )
        	errors.rejectValue( "pdlPb2Parm1", "error.step140.number.invalid.pdlPb2", "Please enter a valid number: PDL-PB/2" );
        if((step.getPdlItuParm1().trim().length()>0 && !NumberUtils.isNumber(step.getPdlItuParm1())) 
        		|| (step.getPdlItuParm2().trim().length()>0 && !NumberUtils.isNumber(step.getPdlItuParm2())) 
        		|| (step.getPdlItuParm3().trim().length()>0 && !NumberUtils.isNumber(step.getPdlItuParm3())) )
        	errors.rejectValue( "pdlItuParm1", "error.step140.number.invalid.pdlItu", "Please enter a valid number: PDL-ITU" );
        if((step.getPdlaPb2Parm1().trim().length()>0 && !NumberUtils.isNumber(step.getPdlaPb2Parm1())) 
        		|| (step.getPdlaPb2Parm2().trim().length()>0 && !NumberUtils.isNumber(step.getPdlaPb2Parm2())) 
        		|| (step.getPdlaPb2Parm3().trim().length()>0 && !NumberUtils.isNumber(step.getPdlaPb2Parm3())) )
        	errors.rejectValue( "pdlaPb2Parm1", "error.step140.number.invalid.pdlaPb2", "Please enter a valid number: PDL+PB/2" );
        if((step.getMinRisoParm1().trim().length()>0 && !NumberUtils.isNumber(step.getMinRisoParm1())) 
        		|| (step.getMinRisoParm2().trim().length()>0 && !NumberUtils.isNumber(step.getMinRisoParm2())) 
        		|| (step.getMinRisoParm3().trim().length()>0 && !NumberUtils.isNumber(step.getMinRisoParm3())) )
        	errors.rejectValue( "minRisoParm1", "error.step140.number.invalid.minRiso", "Please enter a valid number: Min-R-ISO" );
        if((step.getRillParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRillParm1())) 
        		|| (step.getRillParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRillParm2())) 
        		|| (step.getRillParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRillParm3())) )
        	errors.rejectValue( "rillParm1", "error.step140.number.invalid.rill", "Please enter a valid number: R IL-L" );
        if((step.getRilrParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRilrParm1())) 
        		|| (step.getRilrParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRilrParm2())) 
        		|| (step.getRilrParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRilrParm3())) )
        	errors.rejectValue( "rilrParm1", "error.step140.number.invalid.rilr", "Please enter a valid number: R IL-R" );
        if((step.getRipplelParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRipplelParm1())) 
        		|| (step.getRipplelParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRipplelParm2())) 
        		|| (step.getRipplelParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRipplelParm3())) )
        	errors.rejectValue( "ripplelParm1", "error.step140.number.invalid.ripplel", "Please enter a valid number: Ripple/L" );
        if((step.getRipplerParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRipplerParm1())) 
        		|| (step.getRipplerParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRipplerParm2())) 
        		|| (step.getRipplerParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRipplerParm3())) )
        	errors.rejectValue( "ripplerParm1", "error.step140.number.invalid.rippler", "Please enter a valid number: Ripple/R" );
    	//Length invalid
    	if(stepValided){
	    	if(step.getTestLightCode() == null || step.getTestLightCode().trim().length() != 20)
	    		errors.rejectValue( "testLightCode", "error.user.length.invalid.testLightCode", "Please specify Test Light Code with 20 chars." );
    	}
    }
    
    private void validateStep170_2(Step170_2Data step, Errors errors) {
    	//Input empty
    	if(stepValided){
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlRportParm1", "error.step140.empty.rlRportParm1", "Please specify RL(R-Port)/at Adj_L.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlPportParm2", "error.step140.empty.rlPportParm2", "Please specify RL(P-Port)/at ITU.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlRportParm3", "error.step140.empty.rlRportParm3", "Please specify RL(R-Port)/at Adj_R.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlCportParm1", "error.step140.empty.rlCportParm1", "Please specify RL(C-Port))/at Adj_L.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlCportParm2", "error.step140.empty.rlCportParm2", "Please specify RL(C-Port))/at ITU.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rlCportParm3", "error.step140.empty.rlCportParm3", "Please specify RL(C-Port))/at Adj_R.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dirPrParm2", "error.step140.empty.dirPrParm2", "Please specify Dir(P->R)/at ITU.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dirRpParm1", "error.step140.empty.dirRpParm1", "Please specify Dir(R->P)/at Adj_L.");
    		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dirRpParm3", "error.step140.empty.dirRpParm3", "Please specify Dir(R->P)/at Adj_R.");
    	}
    	//Number invalid
        if((step.getRlPportParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRlPportParm2())) 
        		|| (step.getRlPportParm2().trim().length()>0 && step.getRlPportParm2().replace(".", "").trim().length() > 3))
        	errors.rejectValue( "rlPportParm1", "error.step140.number.invalid.rlPport", "Please enter a valid number within 3 digit: RL(P-Port)" );
        if((step.getRlRportParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRlRportParm1())) 
        		|| (step.getRlRportParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRlRportParm3())) 
        		|| (step.getRlRportParm1().trim().length()>0 && step.getRlRportParm1().replace(".", "").trim().length() > 3)
        		|| (step.getRlRportParm3().trim().length()>0 && step.getRlRportParm3().replace(".", "").trim().length() > 3))
        	errors.rejectValue( "rlRportParm1", "error.step140.number.invalid.rlRport", "Please enter a valid number within 3 digit: RL(R-Port)" );
        if((step.getRlCportParm1().trim().length()>0 && !NumberUtils.isNumber(step.getRlCportParm1())) 
        		|| (step.getRlCportParm2().trim().length()>0 && !NumberUtils.isNumber(step.getRlCportParm2())) 
        		|| (step.getRlCportParm3().trim().length()>0 && !NumberUtils.isNumber(step.getRlCportParm3())) 
        		|| (step.getRlCportParm1().trim().length()>0 && step.getRlCportParm1().replace(".", "").trim().length() > 3)
        		|| (step.getRlCportParm2().trim().length()>0 && step.getRlCportParm2().replace(".", "").trim().length() > 3)
        		|| (step.getRlCportParm3().trim().length()>0 && step.getRlCportParm3().replace(".", "").trim().length() > 3))
        	errors.rejectValue( "rlCportParm1", "error.step140.number.invalid.rlCport", "Please enter a valid number within 3 digit: RL(C-Port)" );
        if((step.getDirPrParm2().trim().length()>0 && !NumberUtils.isNumber(step.getDirPrParm2())) 
        		|| (step.getDirPrParm2().trim().length()>0 && step.getDirPrParm2().replace(".", "").trim().length() > 3))
        	errors.rejectValue( "dirPrParm2", "error.step140.number.invalid.dirPr", "Please enter a valid number within 3 digit: Dir(P->R)" );
        if((step.getDirRpParm1().trim().length()>0 && !NumberUtils.isNumber(step.getDirRpParm1())) 
        		|| (step.getDirRpParm3().trim().length()>0 && !NumberUtils.isNumber(step.getDirRpParm3())) 
        		|| (step.getDirRpParm1().trim().length()>0 && step.getDirRpParm1().replace(".", "").trim().length() > 3)
        		|| (step.getDirRpParm3().trim().length()>0 && step.getDirRpParm3().replace(".", "").trim().length() > 3))
        	errors.rejectValue( "dirRpParm1", "error.step140.number.invalid.dirRp", "Please enter a valid number within 3 digit: Dir(R->P)" );
    	//Length invalid
    	if(stepValided){
	    	if(step.getTestLightCode2() == null || step.getTestLightCode2().trim().length() != 20)
	    		errors.rejectValue( "testLightCode2", "error.user.length.invalid.testLightCode", "Please specify Test Light Code with 20 chars." );
    	}
    }
    
    private void validateStep180(Step180Data step, Errors errors) {

    }
    
    private void validateDataSheet(DataSheet sheet, Errors errors) {
    	//Input empty
    	if(stepValided){
//	    	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "internalPo", "error.datasheet.empty.internalPo", "Please specify Internal PO#.");
//	    	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "customerPo", "error.datasheet.empty.customerPo", "Please specify Customer PO#.");
//	    	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "internalPn", "error.datasheet.empty.internalPn", "Please specify Internal P/N.");
//	    	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "sn", "error.datasheet.empty.sn", "Please specify S/N.");
    	}
    	//Length invalid
    	if(stepValided){
	    	if(sheet.getSn() == null || sheet.getSn().trim().length() != 10)
	    		errors.rejectValue( "sn", "error.product.length.invalid.finalSn", "Please specify Final S/N with 10 chars." );
	    	if(sheet.getInternalPo() == null || sheet.getInternalPo().trim().length() != 20)
	    		errors.rejectValue( "internalPo", "error.datasheet.length.invalid.internalPo", "Please specify Internal PO# with 20 chars." );
	    	if(sheet.getCustomerPo() == null || sheet.getCustomerPo().trim().length() != 20)
	    		errors.rejectValue( "customerPo", "error.datasheet.length.invalid.customerPo", "Please specify Customer PO# with 20 chars." );
	    	if(sheet.getCustomerPn() == null || sheet.getCustomerPn().trim().length() != 20)
	    		errors.rejectValue( "customerPn", "error.datasheet.length.invalid.customerPn", "Please specify Customer PN# with 20 chars." );
	    	if(sheet.getInternalPn() == null || sheet.getInternalPn().trim().length() != 20)
	    		errors.rejectValue( "internalPn", "error.datasheet.length.invalid.internalPn", "Please specify Internal P/N with 20 chars." );
	    	if(sheet.getReflectedWavelength() == null || sheet.getReflectedWavelength().trim().length() != 6)
	    		errors.rejectValue( "reflectedWavelength", "error.datasheet.length.invalid.reflectedWavelength", "Please specify Reflected Wavelength with 6 chars." );    	}
    }
    
}
